home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Developer Essentials / MPW Interfaces & Libraries / CIncludes / TextEdit.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-29  |  10.4 KB  |  343 lines  |  [TEXT/MPS ]

  1.  
  2. /************************************************************
  3.  
  4. Created: Friday, November 15, 1991 at 9:57 AM
  5.  TextEdit.h
  6.  C Interface to the Macintosh Libraries
  7.  
  8.  
  9.   Copyright Apple Computer, Inc. 1985-1991
  10.   All rights reserved
  11.  
  12. ************************************************************/
  13.  
  14.  
  15. #ifndef __TEXTEDIT__
  16. #define __TEXTEDIT__
  17.  
  18. #ifndef __QUICKDRAW__
  19. #include <Quickdraw.h>
  20. #endif
  21.  
  22.  
  23. enum {
  24.  
  25.  
  26. /* Justification styles */
  27.  teJustLeft = 0,
  28.  teJustCenter = 1,
  29.  teJustRight = -1,
  30.  teForceLeft = -2,
  31.  
  32. /* new names for the Justification styles */
  33.  teFlushDefault = 0,                                    /*flush according to the line direction */
  34.  teCenter = 1,                                            /*center justify */
  35.  teFlushRight = -1,                                        /*flush right for all scripts */
  36.  teFlushLeft = -2,                                        /*flush left for all scripts */
  37.  
  38. /* Set/Replace style modes */
  39.  fontBit = 0,                                            /*set font*/
  40.  faceBit = 1,                                            /*set face*/
  41.  sizeBit = 2,                                            /*set size*/
  42.  clrBit = 3,                                            /*set color*/
  43.  addSizeBit = 4,                                        /*add size mode*/
  44.  toglBit = 5,                                            /*set faces in toggle mode*/
  45.  
  46. /* TESetStyle/TEContinuousStyle modes */
  47.  doFont = 1,                                            /* set font (family) number*/
  48.  doFace = 2,                                            /*set character style*/
  49.  doSize = 4,                                            /*set type size*/
  50.  doColor = 8,                                            /*set color*/
  51.  doAll = 15,                                            /*set all attributes*/
  52.  addSize = 16                                            /*adjust type size*/
  53. };
  54. enum {
  55.  doToggle = 32,                                            /*toggle mode for TESetStyle & TEContinuousStyle*/
  56.  
  57. /* offsets into TEDispatchRec */
  58.  EOLHook = 0,                                            /*[ProcPtr] TEEOLHook*/
  59.  DRAWHook = 4,                                            /*[ProcPtr] TEWidthHook*/
  60.  WIDTHHook = 8,                                            /*[ProcPtr] TEDrawHook*/
  61.  HITTESTHook = 12,                                        /*[ProcPtr] TEHitTestHook*/
  62.  nWIDTHHook = 24,                                        /*[ProcPtr] nTEWidthHook*/
  63.  TextWidthHook = 28,                                    /*[ProcPtr] TETextWidthHook*/
  64.  
  65. /* selectors for TECustomHook */
  66.  intEOLHook = 0,                                        /*TEIntHook value*/
  67.  intDrawHook = 1,                                        /*TEIntHook value*/
  68.  intWidthHook = 2,                                        /*TEIntHook value*/
  69.  intHitTestHook = 3,                                    /*TEIntHook value*/
  70.  intNWidthHook = 6,                                        /*TEIntHook value for new version of WidthHook*/
  71.  intTextWidthHook = 7,                                    /*TEIntHook value for new TextWidthHook*/
  72.  
  73. /* feature or bit definitions for TEFeatureFlag */
  74.  teFAutoScr = 0,                                        /*00000001b*/
  75.  teFTextBuffering = 1,                                    /*00000010b*/
  76.  teFOutlineHilite = 2,                                    /*00000100b*/
  77.  teFInlineInput = 3,                                    /*00001000b*/
  78.  teFUseTextServices = 4,                                /*00010000b*/
  79.  
  80. /* action for the new "bit (un)set" interface, TEFeatureFlag */
  81.  TEBitClear = 0,
  82.  TEBitSet = 1                                            /*set the selector bit*/
  83. };
  84. enum {
  85.  TEBitTest = -1,                                        /*no change; just return the current setting*/
  86.  
  87. /*constants for identifying the routine that called FindWord */
  88.  teWordSelect = 4,                                        /*clickExpand to select word*/
  89.  teWordDrag = 8,                                        /*clickExpand to drag new word*/
  90.  teFromFind = 12,                                        /*FindLine called it ($0C)*/
  91.  teFromRecal = 16                                        /*RecalLines called it ($10)*/
  92. };
  93.  
  94. typedef pascal Boolean (*WordBreakProcPtr)(Ptr text, short charPos);
  95. typedef pascal Boolean (*ClikLoopProcPtr)(void);
  96.  
  97. struct TERec {
  98.  Rect destRect;
  99.  Rect viewRect;
  100.  Rect selRect;
  101.  short lineHeight;
  102.  short fontAscent;
  103.  Point selPoint;
  104.  short selStart;
  105.  short selEnd;
  106.  short active;
  107.  WordBreakProcPtr wordBreak;
  108.  ClikLoopProcPtr clikLoop;
  109.  long clickTime;
  110.  short clickLoc;
  111.  long caretTime;
  112.  short caretState;
  113.  short just;
  114.  short teLength;
  115.  Handle hText;
  116.  short recalBack;
  117.  short recalLines;
  118.  short clikStuff;
  119.  short crOnly;
  120.  short txFont;
  121.  Style txFace;                                            /*txFace is unpacked byte*/
  122.  char filler;
  123.  short txMode;
  124.  short txSize;
  125.  GrafPtr inPort;
  126.  ProcPtr highHook;
  127.  ProcPtr caretHook;
  128.  short nLines;
  129.  short lineStarts[16001];
  130. };
  131.  
  132. typedef struct TERec TERec;
  133. typedef TERec *TEPtr, **TEHandle;
  134.  
  135. typedef char Chars[32001];
  136. typedef char *CharsPtr,**CharsHandle;
  137.  
  138. struct StyleRun {
  139.  short startChar;                                        /*starting character position*/
  140.  short styleIndex;                                        /*index in style table*/
  141. };
  142.  
  143. typedef struct StyleRun StyleRun;
  144.  
  145. struct STElement {
  146.  short stCount;                                            /*number of runs in this style*/
  147.  short stHeight;                                        /*line height*/
  148.  short stAscent;                                        /*font ascent*/
  149.  short stFont;                                            /*font (family) number*/
  150.  Style stFace;                                            /*character Style*/
  151.  char filler;                                            /*stFace is unpacked byte*/
  152.  short stSize;                                            /*size in points*/
  153.  RGBColor stColor;                                        /*absolute (RGB) color*/
  154. };
  155.  
  156. typedef struct STElement STElement;
  157.  
  158. typedef STElement TEStyleTable[1777], *STPtr, **STHandle;
  159.  
  160. struct LHElement {
  161.  short lhHeight;                                        /*maximum height in line*/
  162.  short lhAscent;                                        /*maximum ascent in line*/
  163. };
  164.  
  165. typedef struct LHElement LHElement;
  166.  
  167. typedef LHElement LHTable[8001], *LHPtr, **LHHandle;    /* ARRAY [0..8000] OF LHElement */
  168.  
  169. struct ScrpSTElement {
  170.  long scrpStartChar;                                    /*starting character position*/
  171.  short scrpHeight;                                        /*starting character position*/
  172.  short scrpAscent;
  173.  short scrpFont;
  174.  Style scrpFace;                                        /*unpacked byte*/
  175.  char filler;                                            /*scrpFace is unpacked byte*/
  176.  short scrpSize;
  177.  RGBColor scrpColor;
  178. };
  179.  
  180. typedef struct ScrpSTElement ScrpSTElement;
  181.  
  182. typedef ScrpSTElement ScrpSTTable[1601];                /* ARRAY [0..1600] OF ScrpSTElement */
  183.  
  184. struct StScrpRec {
  185.  short scrpNStyles;                                        /*number of styles in scrap*/
  186.  ScrpSTTable scrpStyleTab;                                /*table of styles for scrap*/
  187. };
  188.  
  189. typedef struct StScrpRec StScrpRec;
  190. typedef StScrpRec *StScrpPtr, **StScrpHandle;
  191.  
  192. struct NullStRec {
  193.  long teReserved;                                        /*reserved for future expansion*/
  194.  StScrpHandle nullScrap;                                /*handle to scrap style table*/
  195. };
  196.  
  197. typedef struct NullStRec NullStRec;
  198. typedef NullStRec *NullStPtr, **NullStHandle;
  199.  
  200. struct TEStyleRec {
  201.  short nRuns;                                            /*number of style runs*/
  202.  short nStyles;                                            /*size of style table*/
  203.  STHandle styleTab;                                        /*handle to style table*/
  204.  LHHandle lhTab;                                        /*handle to line-height table*/
  205.  long teRefCon;                                            /*reserved for application use*/
  206.  NullStHandle nullStyle;                                /*Handle to style set at null selection*/
  207.  StyleRun runs[8001];                                    /*ARRAY [0..8000] OF StyleRun*/
  208. };
  209.  
  210. typedef struct TEStyleRec TEStyleRec;
  211. typedef TEStyleRec *TEStylePtr, **TEStyleHandle;
  212.  
  213. struct TextStyle {
  214.  short tsFont;                                            /*font (family) number*/
  215.  Style tsFace;                                            /*character Style*/
  216.  char filler;                                            /*tsFace is unpacked byte*/
  217.  short tsSize;                                            /*size in point*/
  218.  RGBColor tsColor;                                        /*absolute (RGB) color*/
  219. };
  220.  
  221. typedef struct TextStyle TextStyle;
  222. typedef TextStyle *TextStylePtr, **TextStyleHandle;
  223.  
  224.  
  225. typedef short TEIntHook;
  226.  
  227. #ifdef __cplusplus
  228. extern "C" {
  229. #endif
  230. pascal void TEInit(void)
  231.  = 0xA9CC; 
  232. pascal TEHandle TENew(const Rect *destRect,const Rect *viewRect)
  233.  = 0xA9D2; 
  234. pascal void TEDispose(TEHandle hTE)
  235.  = 0xA9CD; 
  236. pascal void TESetText(const void *text,long length,TEHandle hTE)
  237.  = 0xA9CF; 
  238. pascal CharsHandle TEGetText(TEHandle hTE)
  239.  = 0xA9CB; 
  240. pascal void TEIdle(TEHandle hTE)
  241.  = 0xA9DA; 
  242. pascal void TESetSelect(long selStart,long selEnd,TEHandle hTE)
  243.  = 0xA9D1; 
  244. pascal void TEActivate(TEHandle hTE)
  245.  = 0xA9D8; 
  246. pascal void TEDeactivate(TEHandle hTE)
  247.  = 0xA9D9; 
  248. pascal void TEKey(short key,TEHandle hTE)
  249.  = 0xA9DC; 
  250. pascal void TECut(TEHandle hTE)
  251.  = 0xA9D6; 
  252. pascal void TECopy(TEHandle hTE)
  253.  = 0xA9D5; 
  254. pascal void TEPaste(TEHandle hTE)
  255.  = 0xA9DB; 
  256. pascal void TEDelete(TEHandle hTE)
  257.  = 0xA9D7; 
  258. pascal void TEInsert(const void *text,long length,TEHandle hTE)
  259.  = 0xA9DE; 
  260. pascal void TESetJust(short just,TEHandle hTE)
  261.  = 0xA9DF; 
  262. pascal void TEUpdate(const Rect *rUpdate,TEHandle hTE)
  263.  = 0xA9D3; 
  264. pascal void TextBox(const void *text,long length,const Rect *box,short just)
  265.  = 0xA9CE; 
  266. pascal void TEScroll(short dh,short dv,TEHandle hTE)
  267.  = 0xA9DD; 
  268. pascal void TESelView(TEHandle hTE)
  269.  = 0xA811; 
  270. pascal void TEPinScroll(short dh,short dv,TEHandle hTE)
  271.  = 0xA812; 
  272. pascal void TEAutoView(Boolean fAuto,TEHandle hTE)
  273.  = 0xA813; 
  274. #define TEScrapHandle() (* (Handle*) 0xAB4)
  275. pascal void TECalText(TEHandle hTE)
  276.  = 0xA9D0; 
  277. pascal short TEGetOffset(Point pt,TEHandle hTE)
  278.  = 0xA83C; 
  279. pascal Point TEGetPoint(short offset,TEHandle hTE)
  280.  = {0x3F3C,0x0008,0xA83D}; 
  281. pascal void TEClick(Point pt,Boolean fExtend,TEHandle h)
  282.  = 0xA9D4; 
  283. pascal TEHandle TEStylNew(const Rect *destRect,const Rect *viewRect)
  284.  = 0xA83E; 
  285. pascal TEHandle TEStyleNew(const Rect *destRect,const Rect *viewRect)
  286.  = 0xA83E; 
  287. pascal void SetStylHandle(TEStyleHandle theHandle,TEHandle hTE)
  288.  = {0x3F3C,0x0005,0xA83D}; 
  289. pascal void SetStyleHandle(TEStyleHandle theHandle,TEHandle hTE)
  290.  = {0x3F3C,0x0005,0xA83D}; 
  291. pascal TEStyleHandle GetStylHandle(TEHandle hTE)
  292.  = {0x3F3C,0x0004,0xA83D}; 
  293. pascal TEStyleHandle GetStyleHandle(TEHandle hTE)
  294.  = {0x3F3C,0x0004,0xA83D}; 
  295. pascal void TEGetStyle(short offset,TextStyle *theStyle,short *lineHeight,
  296.  short *fontAscent,TEHandle hTE)
  297.  = {0x3F3C,0x0003,0xA83D}; 
  298. pascal void TEStylPaste(TEHandle hTE)
  299.  = {0x3F3C,0x0000,0xA83D}; 
  300. pascal void TEStylePaste(TEHandle hTE)
  301.  = {0x3F3C,0x0000,0xA83D}; 
  302. pascal void TESetStyle(short mode,const TextStyle *newStyle,Boolean redraw,
  303.  TEHandle hTE)
  304.  = {0x3F3C,0x0001,0xA83D}; 
  305. pascal void TEReplaceStyle(short mode,const TextStyle *oldStyle,const TextStyle *newStyle,
  306.  Boolean redraw,TEHandle hTE)
  307.  = {0x3F3C,0x0002,0xA83D}; 
  308. pascal StScrpHandle GetStylScrap(TEHandle hTE)
  309.  = {0x3F3C,0x0006,0xA83D}; 
  310. pascal StScrpHandle GetStyleScrap(TEHandle hTE)
  311.  = {0x3F3C,0x0006,0xA83D}; 
  312. pascal void TEStylInsert(const void *text,long length,StScrpHandle hST,
  313.  TEHandle hTE)
  314.  = {0x3F3C,0x0007,0xA83D}; 
  315. pascal void TEStyleInsert(const void *text,long length,StScrpHandle hST,
  316.  TEHandle hTE)
  317.  = {0x3F3C,0x0007,0xA83D}; 
  318. pascal long TEGetHeight(long endLine,long startLine,TEHandle hTE)
  319.  = {0x3F3C,0x0009,0xA83D}; 
  320. pascal Boolean TEContinuousStyle(short *mode,TextStyle *aStyle,TEHandle hTE)
  321.  = {0x3F3C,0x000A,0xA83D}; 
  322. pascal void SetStylScrap(long rangeStart,long rangeEnd,StScrpHandle newStyles,
  323.  Boolean redraw,TEHandle hTE)
  324.  = {0x3F3C,0x000B,0xA83D}; 
  325. pascal void TECustomHook(TEIntHook which,ProcPtr *addr,TEHandle hTE)
  326.  = {0x3F3C,0x000C,0xA83D}; 
  327. pascal long TENumStyles(long rangeStart,long rangeEnd,TEHandle hTE)
  328.  = {0x3F3C,0x000D,0xA83D}; 
  329. pascal short TEFeatureFlag(short feature,short action,TEHandle hTE)
  330.  = {0x3F3C,0x000E,0xA83D}; 
  331. #define TEGetScrapLen() ((long) * (unsigned short *) 0x0AB0)
  332. pascal void TESetScrapLen(long length); 
  333. pascal OSErr TEFromScrap(void); 
  334. pascal OSErr TEToScrap(void); 
  335. pascal void SetClikLoop(ClikLoopProcPtr clikProc,TEHandle hTE); 
  336. pascal void SetWordBreak(WordBreakProcPtr wBrkProc,TEHandle hTE); 
  337. void teclick(Point *pt,Boolean fExtend,TEHandle h); 
  338. #ifdef __cplusplus
  339. }
  340. #endif
  341.  
  342. #endif
  343.